package hips.gui.parameters;

import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.JLabel;
import java.awt.Font;

@SuppressWarnings("rawtypes")
public class ParameterPanel extends javax.swing.JPanel {
	private static final long serialVersionUID = 1L;

	public ParameterPanel(Number defaultOmega, Number maxOmega, Number defaultAlpha, Number maxAlpha) {
		initComponents();

		Comparable zero;
		Number one;
		if (maxOmega instanceof Integer) {
			zero = (Integer) 0;
			one = (Integer) 1;
		} else {
			zero = (Float) 0f;
			one = (Float) 1f;
		}
		omega.setModel(new SpinnerNumberModel(defaultOmega, zero, (Comparable) maxOmega, one));
		alpha.setModel(new SpinnerNumberModel(defaultAlpha, zero, (Comparable) maxAlpha, one));
	}
	
	public Number getOmega() {
		return (Number) omega.getValue();
	}
	
	public Number getAlpha() {
		return (Number) alpha.getValue();
	}

	public void setOmega(Number value) {
		omega.setValue(value);
	}

	public void setAlpha(Number value) {
		alpha.setValue(value);
	}
	
	public JSpinner getOmegaSpinner() {
		return omega;
	}
	
	public JSpinner getAlphaSpinner() {
		return alpha;
	}

	private void initComponents() {
		setBackground(new java.awt.Color(246, 246, 246));
		setLayout(null);
		
		JLabel labelGlobal = new JLabel();
		labelGlobal.setText("Global range parameter:");
		labelGlobal.setFont(new Font("Calibri", 0, 16));
		labelGlobal.setBounds(10, 28, 158, 20);
		add(labelGlobal);

		omega = new JSpinner();
		omega.setFont(new java.awt.Font("Calibri", 0, 16));
		omega.setBounds(178, 22, 150, 32);
		add(omega);

		JLabel labelLocal = new JLabel();
		labelLocal.setText("Local range parameter:");
		labelLocal.setFont(new Font("Calibri", Font.PLAIN, 16));
		labelLocal.setBounds(10, 83, 158, 20);
		add(labelLocal);

		alpha = new JSpinner();
		alpha.setFont(new Font("Calibri", Font.PLAIN, 16));
		alpha.setBounds(178, 77, 150, 32);
		add(alpha);
	}

	private JSpinner alpha;
	private JSpinner omega;
}
